package com.example;

import java.util.LinkedHashMap;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.example.common.ExceptionCodeResolver;
import com.example.common.SimpleMappingExceptionCodeResolver;

@SpringBootApplication
@EnableTransactionManagement
public class JpaTestApplication {

	public static void main(String[] args) {
		SpringApplication.run(JpaTestApplication.class, args);
	}

	@Bean
	public ExceptionCodeResolver exceptionCodeResolver() {

	    LinkedHashMap<String, String> exceptionMappings = new LinkedHashMap<String, String>() {
            private static final long serialVersionUID = 1L;
            {
                put("ResourceNotFoundException", "e.ex.fw.5001");
                put("HttpRequestMethodNotSupportedException", "e.ex.fw.6001");
                put("MediaTypeNotAcceptableException", "e.ex.fw.7001");
	        }
	    };

	    SimpleMappingExceptionCodeResolver exceptionCodeResolver = new SimpleMappingExceptionCodeResolver();
	    exceptionCodeResolver.setExceptionMappings(exceptionMappings);

	    return exceptionCodeResolver;
	}



}
